var year = prompt("请输入年份");
var month = prompt("请输入月份");
year= Number(year);
month= Number(month);
//var year = 2019;
//var month = 5;

function run(year) {
    if (year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)) {
        return true;
    }
    else {
        return false;
    }
}
var days = 0;
for (var i = 1980; i < year; i++) {
    if (run(i)) {
        days += 366;
    }
    else {
        days += 365;
    }
}
for (var s = 1; s < month; s++) {
    switch (s) {
    case 1:
        days += 31;
        break;
    case 2:
        if (run(year)) {
            days += 29
        }
        else {
            days += 28
        }
        break;
    case 3:
        days += 31;
        break;
    case 4:
        days += 30;
        break;
    case 5:
        days += 31;
        break;
    case 6:
        days += 30;
        break;
    case 7:
        days += 31;
        break;
    case 8:
        days += 31;
        break;
    case 9:
        days += 30;
        break;
    case 10:
        days += 31;
        break;
    case 11:
        days += 30;
        break;
    case 12:
        days += 31;
        break;
    }
}
days += 2;
var start = days % 7;
console.log(days);
console.log(start);
var day = document.querySelector("#day");
var preaday = 0;
switch (month - 1) {
case 0:
    preaday += 31;
    break;
case 1:
    preaday += 31;
    break;
case 2:
    if (run(year)) {
        preaday += 29
    }
    else {
        preaday += 28
    }
    break;
case 3:
    preaday += 31;
    break;
case 4:
    preaday += 30;
    break;
case 5:
    preaday += 31;
    break;
case 6:
    preaday += 30;
    break;
case 7:
    preaday += 31;
    break;
case 8:
    preaday += 31;
    break;
case 9:
    preaday += 30;
    break;
case 10:
    preaday += 31;
    break;
case 11:
    preaday += 30;
    break;
case 12:
    preaday += 31;
    break;
}

console.log(preaday);
for(var j=preaday-start+1; j<=preaday; j++){
    day.innerHTML+='<span class="h">'+j+'</span>';
}































var thisday = 0;
switch (month) {
case 1:
    thisday += 31;
    break;
case 2:
    if (run(year)) {
        thisday += 29
    }
    else {
        thisday += 28
    }
    break;
case 3:
    thisday += 31;
    break;
case 4:
    thisday += 30;
    break;
case 5:
    thisday += 31;
    break;
case 6:
    thisday += 30;
    break;
case 7:
    thisday += 31;
    break;
case 8:
    thisday += 31;
    break;
case 9:
    thisday += 30;
    break;
case 10:
    thisday += 31;
    break;
case 11:
    thisday += 30;
    break;
case 12:
    thisday += 31;
    break;
}

var d = new Date().getDate();
for (v=1; v<=thisday; v++){
    if(v==d){
        day.innerHTML+='<span class="today">'+v+'</span>';
    }else{
        day.innerHTML+='<span>'+v+'</span>';
    }
    
}

















var num = 42;
var endday = num-start-thisday;
for(var n = 1; n<=endday; n++){
    day.innerHTML+='<span class="h">'+n+'</span>';
}























document.querySelector("#nian").innerHTML=year;
document.querySelector("#yue").innerHTML=month;